//
//  NSString+HSNSStringExtensionMethods.m
//  hihuasheng
//
//  Created by anlun on 16/1/15.
//  Copyright © 2016年 anLun. All rights reserved.
//

#import "NSString+HSNSStringExtensionMethods.h"

@implementation NSString (HSNSStringExtensionMethods)

- (NSArray *)componentsSeparatedFromString:(NSString *)fromString toString:(NSString *)toString
{
	if (!fromString || !toString || fromString.length == 0 || toString.length == 0) {
		return nil;
	}
	NSMutableArray *subStringsArray = [[NSMutableArray alloc] init];
	NSString *tempString = self;
	NSRange range = [tempString rangeOfString:fromString];
	while (range.location != NSNotFound) {
		tempString = [tempString substringFromIndex:(range.location + range.length)];
		range = [tempString rangeOfString:toString];
		if (range.location != NSNotFound) {
			[subStringsArray addObject:[tempString substringToIndex:range.location]];
			range = [tempString rangeOfString:fromString];
		}
		else
		{
			break;
		}
	}
	return subStringsArray;
}

@end
